/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kungkhies.mvc.kungkho;

import com.kungkhies.services.kungkho.KungkhommenderService;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 *
 * @author clayton
 */
@Controller
public class KungkhoController
{
    private KungkhommenderService kungkhommenderService;
    
    @Autowired
    public KungkhoController(KungkhommenderService kungkhommenderService)
    {
        this.kungkhommenderService = kungkhommenderService;   
    }
    
    @RequestMapping(value = {"/kungkho"}, method = RequestMethod.GET)
    public String showRecommendationsPage(@RequestParam("kungkherName") String kungkherName, Map<String, Object> model)
    {
        System.out.println("KungkhoController: SHOW RECOMMENDATIONS PAGE METHOD");

        if (kungkhommenderService == null)
        {
            System.out.println("kungkhommenderService is null in HomeController constructor");
        }
        else
        {
            System.out.println("kungkhommenderService is NOT null in HomeController constructor");
        }

        if (kungkhommenderService.getKungkhieRecommendations(kungkherName) == null)
        {
            System.out.println("kungkhieService.getRecentKungkhies(5) is null in HomeController constructor");
        }
        else
        {
        }
        
        model.put("kungkhoes", kungkhommenderService.getKungkhieRecommendations(kungkherName));
        return "kungkho";
    }
}
